package bus

import "git.oschina.net/antlinker/antevent/server/store"

// AllBus 所有业务
type AllBus struct {
	listener Listener
	analysis Analysis
	auth     Auth
}

// Option 参数
type Option struct {
	MgoDB        store.MyMgoer
	Listener     store.Listener
	JwtSignedKey string
	ServiceName  string
}

// CreateAllBus 创建一个所有业务模型
func CreateAllBus(opt Option) *AllBus {
	return &AllBus{
		listener: &listener{lstore: opt.Listener},
		analysis: store.CreateAnalysisStore(opt.MgoDB),
		auth:     &auth{jwtSignedKey: []byte(opt.JwtSignedKey), service: opt.ServiceName},
	}
}

// Listener 获取监听处理业务
func (b *AllBus) Listener() Listener {
	return b.listener
}

// Analysis 获取事件分析处理业务
func (b *AllBus) Analysis() Analysis {
	return b.analysis
}

// Analysis 获取事件分析处理业务
func (b *AllBus) Auth() Auth {
	return b.auth
}
